﻿using System;
using System.Windows;
using System.Windows.Forms;

namespace KM.Framework.Business
{
    /// </summary>
    public class BoxHelper
    {
        /// <summary>
        /// 信息提示
        /// </summary>
        /// <param name="content">提示信息</param>
        /// <param name="caption">标题</param>
        /// <param name="callback">返回结果</param>
        public static void Info(string content, string caption="消息框", Action<MessageBoxResult> callback = null, ButtonType button = ButtonType.OK) => Show(content, caption, MessageBoxType.Info, button, callback);

        /// <summary>
        /// 成功信息提示
        /// </summary>
        /// <param name="content">提示信息</param>
        /// <param name="caption">标题</param>
        /// <param name="callback">返回结果</param>
        public static void Success(string content, string caption, Action<MessageBoxResult> callback = null, ButtonType button = ButtonType.OK) => Show(content, caption, MessageBoxType.Success, button, callback);

        /// <summary>
        /// 警告信息提示
        /// </summary>
        /// <param name="content">提示信息</param>
        /// <param name="caption">标题</param>
        /// <param name="callback">返回结果</param>
        public static void Warning(string content, string caption="警告", Action<MessageBoxResult> callback = null, ButtonType button = ButtonType.OK) => Show(content, caption, MessageBoxType.Warning, button, callback);

        /// <summary>
        /// 错误信息提示
        /// </summary>
        /// <param name="content">提示信息</param>
        /// <param name="caption">标题</param>
        /// <param name="callback">返回结果</param>
        public static void Error(string content, string caption= "错误", Action<MessageBoxResult> callback = null, ButtonType button = ButtonType.OK) => Show(content, caption, MessageBoxType.Error, button, callback);

        public static bool Ask(string content, string caption= "消息框")
        {
            bool res = false;
            AskTo(content, caption, callback =>
            {
                if (callback == MessageBoxResult.OK)
                    res = true;
                else
                    res = false;
            });
            return res;
        }
        private static void AskTo(string content, string caption, Action<MessageBoxResult> callback = null, ButtonType button = ButtonType.OKCancel) => Show(content, caption, MessageBoxType.Ask, button, callback);

        public static void Show(string messageBoxText, string caption, MessageBoxType type, ButtonType button = ButtonType.OKCancel, Action<MessageBoxResult> callback = null, string confirmName = "", string cannelName = "")
        {
            MyMessageBox window = new MyMessageBox();
            window.Show(messageBoxText, caption, type, button, callback, confirmName, cannelName);
        }

        public static void WinBoxShow(string txt,string tie="提示")
        {
            System.Windows.Forms.MessageBox.Show(txt, tie, MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.ServiceNotification);
        }
       
    }
}
